package cn.liweixi._04_delay;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;


public class producer {
    public static void main(String[] args) throws Exception {
        //创建一个生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("hahah-delay");
        //连接nameserver
        producer.setNamesrvAddr("127.0.0.1:9876");
        //开启
        producer.start();
        //发送消息
        Message msg = new Message("topic-delay", "tag-delay", "陈扁扁".getBytes(RemotingHelper.DEFAULT_CHARSET));
        msg.setDelayTimeLevel(2);
        SendResult result = producer.send(msg);
        System.out.println(result);
        //关闭
        producer.shutdown();
    }
}
